﻿package baseEngine.system
{
    import baseEngine.basic.*;
    import baseEngine.core.*;
    import com.gengine.core.*;
    import com.gengine.global.*;
    import flash.display.*;
    import flash.display3D.*;
    import flash.geom.*;
    import flash.utils.*;
    import frEngine.util.*;

    public class Global3D extends Object
    {
        public static var loadResource:Boolean = true;
        public static const temporal0:Matrix3D = new Matrix3D();
        public static var scene:Scene3D;
        public static var camera:Camera3D;
        public static var animateSpeedFrame:int = 33;
        public static var profile:String = "baseline";
        public static var openSunLight:Boolean = false;
        public static var timeKeyId:int = 0;
        public static var cameraForward:Vector3D = new Vector3D(0, 0, 1);
        public static var drawCalls3d:int;
        public static var drawCalls2d:int;
        public static var trianglesDrawn:int;
        public static var objectsDrawn:int;
        public static const nullBitmapDataTexture:Texture3D = getNullBitmapDataTexture();
        public static var fps:uint = 0;
        public static var maxTextureSize:int = 2048;
        public static const defaultCullFace:String = "back";
        public static var usedSamples:int;
        public static var usedBuffers:int;
        public static var invertCullMode:Boolean = false;
        public static var ignoreStates:Boolean = false;
        public static var configNum:int = 0;
        private static var _isOpenGL:Boolean = true;
        public static var nullBitmapData:BitmapData;
        private static var AtfClass:Class = Global3D_AtfClass;
        public static const nullAtfTexture:Texture3D = getNullAtfTexture();
        public static var prudenceFrame:Boolean = false;

        public function Global3D()
        {
            return;
        }// end function

        public static function get useGpuParticle() : Boolean
        {
            return !_isOpenGL;
        }// end function

        private static function getNullAtfTexture() : Texture3D
        {
            var _loc_1:* = new AtfClass();
            var _loc_2:* = new Texture3D(_loc_1, Texture3D.MIP_NONE);
            _loc_2.canDispose = false;
            return _loc_2;
        }// end function

        private static function getNullBitmapDataTexture() : Texture3D
        {
            var _loc_2:int = 0;
            nullBitmapData = new BitmapData(64, 64, false, 16711680);
            var _loc_1:int = 0;
            while (_loc_1 < 8)
            {
                
                _loc_2 = 0;
                while (_loc_2 < 8)
                {
                    
                    nullBitmapData.fillRect(new Rectangle(_loc_1 * 8, _loc_2 * 8, 8, 8), (_loc_1 % 2 + _loc_2 % 2) % 2 == 0 ? (16777215) : (11579568));
                    _loc_2++;
                }
                _loc_1++;
            }
            var _loc_3:* = new Texture3D(nullBitmapData, Texture3D.MIP_NONE);
            _loc_3.canDispose = false;
            return _loc_3;
        }// end function

        public static function get isOpenGL() : Boolean
        {
            return _isOpenGL;
        }// end function

        public static function setDiverType(param1:String) : void
        {
            _isOpenGL = param1.indexOf("OpenGL") != -1;
            FrameUtil.driveInfo = param1;
            prudenceFrame = false;
            var _loc_2:* = FrameUtil.isDriverSoftRender ? (30) : (60);
            if (Global.stage)
            {
                Global.stage.frameRate = _loc_2;
            }
            PerformanceUtil.instance.upgradeValue = _loc_2 - 1;
            PerformanceUtil.instance.hasShadowValue = _loc_2 - 5;
            PerformanceUtil.instance.noShadowValue = _loc_2 - 10;
            return;
        }// end function

        public static function set stageFrame(param1:uint) : void
        {
            if (FrameUtil.isDriverSoftRender)
            {
                prudenceFrame = false;
            }
            else
            {
                prudenceFrame = param1 == 30;
            }
            return;
        }// end function

    }
}
